from typing import *
from math import inf


class Solution:

    def findMinDifference(self, timePoints: List[str]) -> int:

        def f(s):
            return int(s[:2]) * 60 + int(s[3:])

        t = []
        for s in timePoints:
            t.append(f(s))
            t.append(f(s) + 1440)
        t.sort()
        ans = inf
        l = t[0]
        for i in range(1, len(t)):
            c = t[i]
            ans = min(ans, c - l)
            l = c
        return ans


class Solution:

    def findMinDifference(self, timePoints: List[str]) -> int:

        def f(s):
            return int(s[:2]) * 60 + int(s[3:])

        t = []
        for s in timePoints:
            t.append(f(s))
        t.sort()
        t.append(t[0] + 1440)
        ans = inf
        l = t[0]
        for i in range(1, len(t)):
            c = t[i]
            ans = min(ans, c - l)
            l = c
        return ans


class Solution:

    def findMinDifference(self, timePoints: List[str]) -> int:

        def f(s):
            return int(s[:2]) * 60 + int(s[3:])

        timePoints.sort()
        l = f(timePoints[0])
        ans = l + 1440 - f(timePoints[-1])
        for i in range(1, len(timePoints)):
            c = f(timePoints[i])
            ans = min(ans, c - l)
            l = c
        return ans


s = Solution()
print(s.findMinDifference(["05:31", "22:08", "00:35"]) == 147)
print(s.findMinDifference(["01:39", "10:26", "21:43"]) == 236)